<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>SetMouseDelay</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>SetMouseDelay</h1>

<p>Sets the delay that will occur after each mouse movement or click.</p>

<pre class="Syntax">SetMouseDelay, Delay [, Play]</pre>
<h3>Parameters</h3>
<dl>

  <dt>Delay</dt>
  <dd><p>Time in milliseconds, which can be an <a href="../Variables.htm#Expressions">expression</a>. Use -1 for no delay at all and 0 for the smallest possible delay (however, if the <em>Play</em> parameter is present, both 0 and -1 produce no delay). If unset, the default delay is 10 for the traditional SendEvent mode and -1 for <a href="Send.htm#SendPlayDetail">SendPlay mode</a>.</p></dd>

  <dt>Play<br>
    <span class="ver">[v1.0.43+]</span></dt>
  <dd><p>The word <em>Play</em> applies the delay to the <a href="Send.htm#SendPlayDetail">SendPlay mode</a> rather than the traditional Send/SendEvent mode. If a script never uses this parameter, the delay is always -1 for SendPlay.</p></dd>

</dl>

<h3>Remarks</h3>
<p>A short delay (sleep) is done automatically after every mouse movement or click generated by <a href="Click.htm">Click</a> and <a href="MouseMove.htm">MouseMove</a>/<a href="MouseClick.htm">Click</a>/<a href="MouseClickDrag.htm">Drag</a> (except for <a href="SendMode.htm">SendInput mode</a>). This is done to improve the reliability of scripts because a window sometimes can't keep up with a rapid flood of mouse events.</p>
<p>Due to the granularity of the OS's time-keeping system, delays might be rounded up to the nearest multiple of 10 or 15. For example, a delay between 1 and 10 (inclusive) is equivalent to 10 or 15 on most Windows XP systems (and probably 2k).</p>
<p>A delay of 0 internally executes a Sleep(0), which yields the remainder of the script's timeslice to any other process that may need it. If there is none, Sleep(0) will not sleep at all. By contrast, a delay of -1 will never sleep.</p>
<p>The built-in variable <strong>A_MouseDelay</strong> contains the current setting for Send/SendEvent mode (there is no built-in variable for <a href="Send.htm#SendPlayDetail">SendPlay mode</a>).</p>
<p>Every newly launched <a href="../misc/Threads.htm">thread</a> (such as a <a href="../Hotkeys.htm">hotkey</a>, <a href="Menu.htm">custom menu item</a>, or <a href="SetTimer.htm">timed</a> subroutine) starts off fresh with the default setting for this command. That default may be changed by using this command in the auto-execute section (top part of the script).</p>
<h3>Related</h3>
<p><a href="SetDefaultMouseSpeed.htm">SetDefaultMouseSpeed</a>, <a href="Click.htm">Click</a>, <a href="MouseMove.htm">MouseMove</a>, <a href="MouseClick.htm">MouseClick</a>, <a href="MouseClickDrag.htm">MouseClickDrag</a>, <a href="SendMode.htm">SendMode</a>, <a href="SetKeyDelay.htm">SetKeyDelay</a>, <a href="SetControlDelay.htm">SetControlDelay</a>, <a href="SetWinDelay.htm">SetWinDelay</a>, <a href="SetBatchLines.htm">SetBatchLines</a></p>
<h3>Example</h3>
<pre class="NoIndent">SetMouseDelay, 0</pre>

</body>
</html>
